//
//  ViewController.m
//  DemoForWK
//
//  Created by 胡碧涛 on 2018/9/20.
//  Copyright © 2018年 Synjones. All rights reserved.
//

#import "ViewController.h"
#import <WebKit/WebKit.h>
#import "WebViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view, typically from a nib.
    NSArray *titleArray = @[@"互调方式", @"请求头方式", @"cookie方式"];
    for (int i = 0; i<3; i++) {
        CGFloat y = 0;
        if (i==0) {
            y = 200;
        } else if (i==1) {
            y = 290;
        } else {
            y = 380;
        }
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(20, y, kScreenWidth-40, 70)];
        button.backgroundColor = [UIColor yellowColor];
        button.tag = i+10;
        [button setTitle:titleArray[i] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(webViewAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
    }
    
    UILabel *tokenLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 500, kScreenWidth-60, 30)];
    tokenLabel.text = [NSString stringWithFormat:@"token:%@", self.token];
    tokenLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:tokenLabel];
}

- (void)webViewAction:(UIButton *)button{
    NSInteger tag = button.tag;
    WebViewController *webView = [[WebViewController alloc] init];
    webView.token = self.token;
    [self.navigationController pushViewController:webView animated:YES];
    webView.strwich = [NSString stringWithFormat:@"%ld",(long)button.tag];
    switch (tag) {
        case 0:
        webView.strwich = @"0";
            break;
        case 1:
            webView.strwich = @"1";
            break;
        case 2:
            webView.strwich = @"2";
            break;
        default:
            break;
    }
}
@end
